package org.shop.controller.manager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.shop.entity.security.MyUserDetail;
import org.shop.service.StatisticalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ManagerStatisticalController {
	@Autowired
    private StatisticalService statisticalService;
	
	@RequestMapping("manager/monthPurchaseStatistical")
	@ResponseBody
	public List<Map<String, Object>> managerMonthPurchaseStatistical(){
		MyUserDetail ud = (MyUserDetail) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("schoolId", ud.getSchoolId());
		return statisticalService.getGoodsMonthPurchaseCount(paramMap);
	}
	@RequestMapping("manager/dayPurchaseStatistical")
	@ResponseBody
	public List<Map<String, Object>> managerDayPurchaseStatistical(){
		MyUserDetail ud = (MyUserDetail) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("schoolId", ud.getSchoolId());
		return statisticalService.getGoodsDayPurchaseCount(paramMap);
	}
	
	@RequestMapping("manager/merchantPurchaseStatistical")
	@ResponseBody
	public List<Map<String, Object>> merchantPurchaseStatistical(){
		MyUserDetail ud = (MyUserDetail) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("schoolId", ud.getSchoolId());
		return statisticalService.getMerchantPurchaseCount(paramMap);
	}
	
	/**
	 * 按月份统计订单金额
	 * @param paramMap
	 * @return
	 */
	@RequestMapping("manager/getMonthGoodsMonthOfSalesMoney")
	@ResponseBody
	public List<Map<String,Object>> getMonthGoodsMonthOfSalesMoney(HttpServletRequest req){
		MyUserDetail ud = (MyUserDetail) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("schoolId", ud.getSchoolId());
		return statisticalService.getGoodsMonthOfSalesMoney(paramMap);
	}
	/**
	 * 统计用户的月活统计
	 * @param paramMap
	 * @return
	 */
	@RequestMapping("manager/getUserOfMonthLoginRecord")
	@ResponseBody
	public List<Map<String,Object>> getUserOfMonthLoginRecord(HttpServletRequest req){
		Map<String, Object> paramMap=new HashMap<String, Object>();
		return statisticalService.getUserOfMonthLoginRecord(paramMap);	
	}
	/**
	 * 统计用户的日活统计
	 * @param paramMap
	 * @return
	 */
	@RequestMapping("manager/getUserOfDayLoginRecord")
	@ResponseBody
	public List<Map<String,Object>> getUserOfDayLoginRecord(HttpServletRequest req){
		Map<String, Object> paramMap=new HashMap<String, Object>();
		return statisticalService.getUserOfDayLoginRecord(paramMap);	
	}
	
	
	
}
